#ifndef __CINT__
# include <AliAnalysisManager.h>
#else 
class AliAnalysisManager;
#endif
#include "TrainSetup.C"
class MyTrain : public TrainSetup
{
public:
  MyTrain(const char* name="myTest") : TrainSetup(name) { SetType(kESD); }
  void CreateTasks(EMode mode, Bool_t par, AliAnalysisManager* mgr)
  {
    printf("test0!\n");

    if (!MakeScriptPAR(mode, "MyAnalysis.C", 
                       "STEERBase,ESD,AOD,ANALYSIS,OADB,ANALYSISalice"))
      Fatal("CreateTasks", "Failed to create PAR file");
   
    LoadLibrary("MyAnalysis", true, true);

    printf("test1!\n");

    printf("test2!\n");

    const char *tkn0 = "AODpkRaa";

    Long_t             r = gROOT->ProcessLine("new AliAnalysisTaskAODpkRaa");
    AliAnalysisTaskSE* mytask = reinterpret_cast<AliAnalysisTaskSE*>(r);

    if (!mytask) Fatal("CreateTasks", "Failed to make task");

    printf("test3!\n");

    //NOT for AOD!!!
    //mytask->SelectCollisionCandidates(AliVEvent::kMB);
  
    mgr->AddTask(mytask);

    //---  
    AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
    mgr->ConnectInput(mytask,  0, cinput );
    
    const TString foutname=Form("xlu_%s",tkn0);
    
    AliAnalysisDataContainer *outlist1 = mgr->CreateContainer("xlu_tree",            TTree::Class(), AliAnalysisManager::kOutputContainer,foutname+"_tree.root");
    AliAnalysisDataContainer *outlist2 = mgr->CreateContainer("xlu_list",            TList::Class(), AliAnalysisManager::kOutputContainer,foutname+"_hist.root");
    
    //in AnalysisTaskSE, slot 0 reserved, must start from 1
    mytask->ConnectOutput(1, outlist1);
    mytask->ConnectOutput(2, outlist2);

    printf("test4!\n");
  }

  void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {}
  AliVEventHandler* CreateOutputHandler(EType type) { return 0; }
  const char* ClassName() const { return "MyTrain"; }
};
//
// EOF
//
